<script type="text/javascript">
    $(function () {
        $.fn.dataGridOptions.addBorrowFormSubFun("#form", '/modules/additional/enjoyGoods/doModify.html');


    });
</script>
<form id="form" method="post" enctype="multipart/form-data">
    <input type="hidden" id="id" name="id" value="${enjoyGoods.id}"/>
    <#if isBorrow>
        <input type="hidden" name="name" value="${enjoyGoods.name}"/>
        <input type="hidden" name="prefecture" value="${enjoyGoods.prefecture}"/>
        <input type="hidden" name="costPrice" value="${enjoyGoods.costPrice}"/>
        <input type="hidden" name="price" value="${enjoyGoods.price}"/>
    </#if>
    <div class="popForm sForm">
        <#if !isBorrow>
            <div class="formitm">
                <label class="lab">名称：</label>
                <div class="ipt"><input type="text" name="name" value="${enjoyGoods.name}" style="width:120px;"
                                        class="name easyui-validatebox"
                                        data-options="required: true,validType:'maxLength[15]'"></div>
            </div>
            <div class="formitm">
                <label class="lab">专区：</label>

                <div class="ipt">
                    <select name="prefecture" id="prefecture">
                        <#list prefectureMap.keySet() as Key>
                            <#if Key==enjoyGoods.prefecture>
                                <option value="${Key}"  selected >
                                    ${prefectureMap.get(Key)}
                                </option>
                                <#else>
                                    <option value="${Key}">
                                        ${prefectureMap.get(Key)}
                                    </option>
                            </#if>
                        </#list>
                    </select>
                </div>
            </div>
        </#if>
        <div class="formitm">
            <label class="lab">描述：</label>

            <div class="ipt"><input type="text" name="content" value="${enjoyGoods.content}" style="width:400px;"
                                    class="name easyui-validatebox"
                                    data-options="required: true,validType:'maxLength[51]'"></div>
        </div>
        <div class="formitm">
            <label class="lab">位置：</label>

            <div class="ipt">
                    <select name="position" id="position">
                        <#list enablePosition as item>
                            <option value="${item}" <#if item == enjoyGoods.position>selected </#if> >${item}</option>
                        </#list>
                    </select>
                9 代表隐藏
            </div>
        </div>
        <#if !isBorrow>
            <div class="formitm">
                <label class="lab">成本价：</label>

                <div class="ipt"><input type="text" name="costPrice" value="${enjoyGoods.costPrice}" style="width:60px;"
                                        onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"
                                        class="amount easyui-validatebox int_figure_required"
                                        data-options="required: true, validType:['numOnly','accout[1,10000]']"
                                        maxlength="5">元
                </div>
            </div>
            <div class="formitm">
                <label class="lab">销售价：</label>

                <div class="ipt"><input type="text" name="price" value="${enjoyGoods.price}" style="width:60px;"
                                        onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"
                                        class="amount easyui-validatebox int_figure_required"
                                        data-options="required: true, validType:['numOnly','accout[1,10000]']"
                                        maxlength="5">元
                </div>
            </div>
            <!--<div class="formitm">-->
            <!--<label class="lab">总数：</label>-->

            <!--<div class="ipt"><input type="text" name="amount" value="${enjoyGoods.amount}" style="width:60px;"-->
            <!--onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"-->
            <!--class="quota easyui-validatebox int_figure_required"-->
            <!--data-options="required: true, validType:['numOnly','copies[1, 100000]']"-->
            <!--maxlength="6">份-->
            <!--</div>-->
            <!--</div>-->
        </#if>
    </div>

    <#if !isBorrow>
        <div class="borrowForm">
            <h1 class="borrowFormTitle">商品介绍图片</h1>

            <div id="uploadGuaranteeBox" class="uploadWrap" data-arr="uploadFile">
                <ul id="borrowPagePic" class="photoUpload">
                    <li class="addFileBtn">
                        <input type="file" name="file" class="uploadFileInput" id="uploadFile"
                               onchange="return ajaxFileUpload1('uploadFile','/imageUp.jsp?editorid=borrow','picPath');"
                               title="点击上传图片"/>
                    </li>
                    <#list picList as pic>
                        <#if pic.type==2>
                            <li data-mum="${pic.id}">
                                <a href="${image_server_url}${pic.picPath}" class="fileshow" rel="guaranteePic"><img
                                        src="${image_server_url}${pic.picPath}"/></a>
                                <a class="closePic" style="float:left;" href="javascript:;" title="删除图片">x</a>
                            </li>
                        </#if>
                    </#list>
                </ul>
            </div>
        </div>
        <!-- 图片列表 -->
        <div class="borrowForm">
            <h1 class="borrowFormTitle">商品图片</h1>

            <div class="uploadWrap" data-arr="uploadFile">
                <ul id="thumbnailPic" class="photoUpload">
                    <li class="addFileBtn">
                        <input type="file" name="thumbnailFile" class="uploadFileInput" id="uploadThumbnailFile"
                               onchange="return ajaxFileUpload3('uploadThumbnailFile','/imageUp.jsp?editorid=borrow','thumbnailPath');"
                               title="点击上传图片"/>
                    </li>
                    <#list picList as pic>
                        <#if pic.type==1>
                            <li data-mum="${pic.id}">
                                <a href="${image_server_url}${pic.picPath}" class="fileshow" rel="guaranteePic"><img
                                        src="${image_server_url}${pic.picPath}"/></a>
                                <a class="closePic" style="float:left;" href="javascript:;" title="删除图片">x</a>
                            </li>
                        </#if>
                    </#list>
                </ul>
            </div>
        </div>
    </#if>
</form>
<#if !isBorrow>
    <script type="text/javascript">seajs.use("${theme_dir}/js/ajaxfileupload");
    seajs.use("${theme_dir}/js/upload");</script>
    <!-- 图片预览-->
    <script type="text/javascript">


        $(".fileshow").fancybox();
        $('.l-btn-text').click(function () {
            if ($("#borrowPagePic li").length <= 1) {
                layer.alert('请上传图片资料', 8);
                return false;
            }

            /*
            if ($("#thumbnailPic li").length <= 1) {
                layer.alert('请上传缩略图', 8);
                return false;
            }
            */
        })
        $("#prefecture").change(function () {
            $.ajax({
                type: "get",
                url: "/modules/additional/enjoyGoods/enablePosition.html?prefecture=" + $(this).val()+"&enjoyGoodsId="+$("#id").val(),
                dataType: "json",
                async: false,
                success: function (data) {
                    var posHtml = [];
                    for (var i = 0, len = data.position.length; i < len; i++) {
                        if (i == 0) {
                            posHtml.push('<option selected="selected" value="' + data.position[i] + '">' + data.position[i] + '</option>');
                        } else {
                            posHtml.push('<option value="' + data.position[i] + '">' + data.position[i] + '</option>');
                        }
                    }
                    $("#position").html(posHtml.join(""));
                }
            });

        })
    </script>
</#if>

